#include "msp_usb.h"

PCD_HandleTypeDef hpcd_USB_FS;

// USB init function
void MSP_USB_PCD_Init(void)
{
    hpcd_USB_FS.Instance = USB;
    hpcd_USB_FS.Init.dev_endpoints = 8;
    hpcd_USB_FS.Init.speed = PCD_SPEED_FULL;
    hpcd_USB_FS.Init.low_power_enable = DISABLE;
    hpcd_USB_FS.Init.lpm_enable = DISABLE;
    hpcd_USB_FS.Init.battery_charging_enable = DISABLE;
    if (HAL_PCD_Init(&hpcd_USB_FS) != HAL_OK)
    {
        // Error_Handler();
    }
}

void HAL_PCD_MspInit(PCD_HandleTypeDef *pcdHandle)
{

    if (pcdHandle->Instance == USB)
    {
        /* USB clock enable */
        __HAL_RCC_USB_CLK_ENABLE();
    }
}

void HAL_PCD_MspDeInit(PCD_HandleTypeDef *pcdHandle)
{

    if (pcdHandle->Instance == USB)
    {
        /* Peripheral clock disable */
        __HAL_RCC_USB_CLK_DISABLE();
    }
}
